package com.example.hibernate.model.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "DEPARTMENTS", schema = "HB")
@SequenceGenerator(name = "SEQ_GEN", sequenceName = "DEPT_SEQ", initialValue = 1, allocationSize = 1)
public class Department extends AbstractEntity {

	private String name;
	private String description;
	private Set<Employee> employees;

	public Department() {
		this.employees = new HashSet<Employee>();
	}

	@Column(name = "DEPT_NAME", nullable = false, length = 75)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "DESCRIPTION", nullable = true, length = 255)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(mappedBy = "department", fetch = FetchType.EAGER)
	public Set<Employee> getEmployees() {
		return employees;
	}

	public void setEmployees(Set<Employee> employees) {
		this.employees = employees;
	}

	@Override
	public String toString() {
		return getName();
	}

}
